#!/usr/bin/env python
# -*- coding:utf-8 -*-

# file:homework10_2.py
# author:wmf
# datetime:2021/5/23 19:52
# software: PyCharm
'''
this is function description
'''
# import module your need
from homework10.homework10_2 import db


def dbInsert(**kwargs):
    # 获取游标
    cursor = db.cursor()
    name = kwargs.get('name')
    age = kwargs.get('age')
    classID = kwargs.get('classID')
    sex = kwargs.get('sex')
    isdeleted = kwargs.get('isdeleted')

    sql = '''insert into test.student(name,age,sex,classID,isdeleted)
             values('{}', {}, '{}', '{}', {})'''.format(name, age, sex, classID, isdeleted)

    try:
        cursor.execute(sql)
        db.commit()
        print("添加成功!")
        db.close()
    except:
        db.rollback()
        db.close()


if __name__ == '__main__':
    dbInsert(name='李四', age=19, sex='男', classID='2', isdeleted=0)
